/****** Object:  Stored Procedure [dbo].spChiTietBienBanNhapHangSelectAllByMaBBNH Script Date: 7/16/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spBienBanNhapHangGetForPrint]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spBienBanNhapHangGetForPrint]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		26/07/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spBienBanNhapHangGetForPrint]
(
	@MaBBNH nvarchar(12)
)
WITH ENCRYPTION

AS

SET NOCOUNT ON

SELECT 
	*
	
FROM 
	[tbl_ChiTietBienBanNhapHang] INNER JOIN tbl_ChiTietPhieuNhap on tbl_ChiTietPhieuNhap.MaCTPN = tbl_ChiTietBienBanNhapHang.MaCTPN
	INNER JOIN tbl_LuuKho ON tbl_LuuKho.MaLuuKho = tbl_ChiTietPhieuNhap.MaLuuKho
	INNER JOIN tbl_PhieuNhap ON tbl_PhieuNhap.soPN = tbl_ChiTietPhieuNhap.soPN
	INNER JOIN tbl_BienBanNhapHang ON [tbl_ChiTietBienBanNhapHang].MaBBNH = tbl_BienBanNhapHang.MaBBNH
	INNER JOIN tbl_SanPham ON tbl_SanPham.MaThuoc =tbl_LuuKho.Mathuoc
	INNER JOIN tbl_DonViTinh ON tbl_DonViTinh.MaDonVi = tbl_SanPham.MaDonVi
WHERE tbl_BienBanNhapHang.[MaBBNH] = @MaBBNH

select * from tbl_Congty
GO

--GRANT EXECUTE ON [dbo].[spChiTietBienBanNhapHangSelectAllByMaBBNH] TO [sa]
--GO
